﻿using Kingdee.BOS.Core.Bill.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace Caraya.MFG.BusinessPlugIn
{
    [Description("控件调试插件"), HotUpdate]
    public class ControlTestPlugIn : AbstractBillPlugIn
    {
        private int nodeId = 999990;
        public override void ButtonClick(ButtonClickEventArgs e)
        {
            base.ButtonClick(e);
            if (e.Key == "F_CARA_BUTTON")
            {
                var tv = this.View.GetControl<TreeView>("F_CARA_TREEVIEW");
                tv.ClearAllNode();
            }
        }

        public override List<TreeNode> GetTreeViewData(TreeNodeArgs e)
        {
            if (e.NodeId == "0")
            {
                // 根节点
                // TODO
            }
            var nodes = new List<TreeNode>();
            var node = new TreeNode();
            node.id = nodeId++.ToString();
            node.Number = "测试节点" + nodeId;
            node.Name = "测试节点" + nodeId;
            node.text = "测试节点" + nodeId;
            node.parentid = e.NodeId;
            node.cls = "parentnode";
            node.children = null;
            nodes.Add(node);
            node = new TreeNode();
            node.id = nodeId++.ToString();
            node.Number = "测试节点" + nodeId;
            node.Name = "测试节点" + nodeId;
            node.text = "测试节点" + nodeId;
            node.parentid = e.NodeId;
            node.cls = "parentnode";
            node.children = null;
            nodes.Add(node);
            return nodes;
        }
    }
}
